'use strict';

const Service = require('egg').Service;

class ProductService extends Service {
    async list(classify_id) {
        let sql = classify_id ? `select * from productlist where classify_id=${classify_id}` : 'select * from productlist';
        return await this.app.mysql.query(sql)
    }
    //搜索
    async search(key){
        return await this.app.mysql.query(`select * from productlist where title like '%${key}%'`)
    }

    //获取详情
    async detail(id){
        return await this.app.mysql.query('select * from productlist where id=?',[id])
    }
}

module.exports = ProductService;
